<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <style>
    html {
      width: 100%;
      height: 100%;
    }

    body {
      width: 100%;
      height: 100%;
    }

    .container {
      position: relative;
      height: 100%;
      width: 100%
        /* height:0; padding-bottom:50% */
    }

    .box {
      position: absolute;
      top: 50px;
      right: 50px;
      bottom: 50px;
      left: 50px;
      background-color: red;
    }
  </style>
</head>

<body>
  <!-- <div class="container"> -->
    <div class="box">
      或者使用另一种方法，就是不给 html body 设置宽高，也不需要父容器，只给 box 设置样式。
    </div>
  <!-- </div> -->
</body>

</html>